package jia.core.media;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.awt.*;
import java.io.File;
import java.io.IOException;

/**
 * @author Erik Stell
 * @version 1.0
 *          Date: Sep 13, 2007
 */
public class Sprite{

	public static int DEFAULT_X = 0;
	public static int DEFAULT_Y = 0;
	public static int DEFAULT_W = 48;
	public static int DEFAULT_H = 48;

	public static int ATTACK_X = 48;
	public static int ATTACK_Y = 0;
	public static int ATTACK_W = 48;
	public static int ATTACK_H = 48;

	public static int DEFAULT_SCALE_W = 48;
	public static int DEFAULT_SCALE_H = 48;


	public static BufferedImage getMainSpriteSheet(String imagePath) throws IOException{
		return ImageIO.read(new File(imagePath));
	}

	public static BufferedImage getDefaultSprite(BufferedImage mainSheet){
		return mainSheet.getSubimage(DEFAULT_X, DEFAULT_Y, DEFAULT_W, DEFAULT_H);
	}

	public static BufferedImage getAttackSprite(BufferedImage mainSheet){
		return mainSheet.getSubimage(ATTACK_X, ATTACK_Y, ATTACK_W, ATTACK_H);
	}

	public static Image returnScaledImage(BufferedImage spriteImage){
		return spriteImage.getScaledInstance(DEFAULT_SCALE_W, DEFAULT_SCALE_H, Image.SCALE_DEFAULT);
	}
}
